import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from "axios"
import { Loading } from 'element-ui';

import "@/assets/icon/iconfont.css"

Vue.prototype.axios = axios
// axios.defaults.baseURL = 'http://www.thenewstep.cn/v1/vue3system/api';

Vue.config.productionTip = false

Vue.use(ElementUI);

let loading
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
  // 显示loading
   loading = Loading.service({
    fullscreen:true,
    text:'正在加载,请稍后...',
    background:"rgba(0,0,0,0.7)"
   })
  // 在发送请求之前做些什么
  config.headers.Authorization = localStorage.getItem('token')
  return config;
}, function (error) {
  // 对请求错误做些什么
  return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
  // 关闭loading
  loading.close()
  // 对响应数据做点什么
  return response;
}, function (error) {
  // 对响应错误做点什么
  return Promise.reject(error);
});


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
